﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Admin_Users_Delete : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
      // For admin pages, check the current user is an admin person
      if (!Conn.IsAdminUser())
      {
        Response.Redirect("Default.aspx");
      }

      litEmail.Text = Request.Params["email"];
    }
    protected void bnDelete_Click(object sender, EventArgs e)
    {
      using (SqlConnection conn = Conn.GetOpened())
      {
        string sql = "delete from users where email=@email";
        SqlCommand cmd = new SqlCommand(sql, conn);
        cmd.Parameters.AddWithValue("@email", Request.Params["email"]);
        cmd.ExecuteNonQuery();
      }
      Response.Redirect("Admin-Users.aspx");
    }
}
